
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>图形图像 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="share.html" />
    
    
    <link rel="prev" href="system.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../introduction/environment.html">
            
                <a href="../introduction/environment.html">
            
                    
                    环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../introduction/hello.html">
            
                <a href="../introduction/hello.html">
            
                    
                    HelloWorld
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../introduction/dev-and-debug.html">
            
                <a href="../introduction/dev-and-debug.html">
            
                    
                    开发与调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    参考
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../framework/file.html">
            
                <a href="../framework/file.html">
            
                    
                    文件组织
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../framework/manifest.html">
            
                <a href="../framework/manifest.html">
            
                    
                    manifest文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../framework/nml.html">
            
                <a href="../framework/nml.html">
            
                    
                    nml文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../framework/page.html">
            
                <a href="../framework/page.html">
            
                    
                    页面与组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    组件
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../component/general.html">
            
                <a href="../component/general.html">
            
                    
                    通用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../component/container.html">
            
                <a href="../component/container.html">
            
                    
                    容器组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../component/basics.html">
            
                <a href="../component/basics.html">
            
                    
                    基础组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../component/form.html">
            
                <a href="../component/form.html">
            
                    
                    表单组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../component/media.html">
            
                <a href="../component/media.html">
            
                    
                    媒体组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    接口
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="general.html">
            
                <a href="general.html">
            
                    
                    通用规则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="basic.html">
            
                <a href="basic.html">
            
                    
                    基本功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="interface.html">
            
                <a href="interface.html">
            
                    
                    界面交互
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="request.html">
            
                <a href="request.html">
            
                    
                    网络访问
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="storage.html">
            
                <a href="storage.html">
            
                    
                    文件数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="system.html">
            
                <a href="system.html">
            
                    
                    系统能力
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.7" data-path="media.html">
            
                <a href="media.html">
            
                    
                    图形图像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="share.html">
            
                <a href="share.html">
            
                    
                    分享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="pay.html">
            
                <a href="pay.html">
            
                    
                    支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="stat.html">
            
                <a href="stat.html">
            
                    
                    统计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >图形图像</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x591A;&#x5A92;&#x4F53;">&#x591A;&#x5A92;&#x4F53;</h3>
<h4 id="&#x63A5;&#x53E3;&#x58F0;&#x660E;">&#x63A5;&#x53E3;&#x58F0;&#x660E;</h4>
<p>{&quot;name&quot;: &quot;system.media&quot;}</p>
<h4 id="unimediatakephotoobject">uni.media.takePhoto(OBJECT)</h4>
<p>&#x62CD;&#x6444;&#x7167;&#x7247;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">cancel</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x53D6;&#x6D88;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x9009;&#x53D6;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">201</td>
<td style="text-align:left">&#x7528;&#x6237;&#x62D2;&#x7EDD;&#xFF0C;&#x83B7;&#x53D6;&#x76F8;&#x673A;&#x6743;&#x9650;&#x5931;&#x8D25;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.takePhoto({
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling success: &quot;</span> + data.uri);
  }
});
</code></pre>
<h4 id="unimediatakevideoobject">uni.media.takeVideo(OBJECT)</h4>
<p>&#x62CD;&#x6444;&#x89C6;&#x9891;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">cancel</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x53D6;&#x6D88;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x9009;&#x53D6;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">201</td>
<td style="text-align:left">&#x7528;&#x6237;&#x62D2;&#x7EDD;&#xFF0C;&#x83B7;&#x53D6;&#x76F8;&#x673A;&#x6743;&#x9650;&#x5931;&#x8D25;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.takeVideo({
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling success: &quot;</span> + data.uri);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h4 id="unimediapickimageobject">uni.media.pickImage(OBJECT)</h4>
<p>&#x9009;&#x62E9;&#x56FE;&#x7247;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">cancel</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x53D6;&#x6D88;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success&#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x9009;&#x53D6;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.pickImage({
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling success: &quot;</span> + data.uri);
  }
});
</code></pre>
<h4 id="unimediapickvideoobject">uni.media.pickVideo(OBJECT)</h4>
<p>&#x9009;&#x62E9;&#x89C6;&#x9891;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">cancel</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x53D6;&#x6D88;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success&#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x9009;&#x53D6;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.pickVideo({
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling success: &quot;</span> + data.uri);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h4 id="unimediacompressimageobject">uni.media.compressImage(OBJECT)</h4>
<p>&#x538B;&#x7F29;&#x6307;&#x5B9A;&#x8DEF;&#x5F84;&#x7684;&#x56FE;&#x7247;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x9ED8;&#x8BA4;&#x503C;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">srcUri</td>
<td style="text-align:left">String</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x6E90;&#x6587;&#x4EF6;&#x7684;uri</td>
</tr>
<tr>
<td style="text-align:left">quality</td>
<td style="text-align:left">Number</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x7684;&#x538B;&#x7F29;&#x8D28;&#x91CF;&#xFF0C;0-100&#x4E4B;&#x95F4;</td>
</tr>
<tr>
<td style="text-align:left">radio</td>
<td style="text-align:left">Number</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5C3A;&#x5BF8;&#x538B;&#x7F29;&#x500D;&#x6570;&#xFF0C;&#x503C;&#x8D8A;&#x5927;&#xFF0C;&#x56FE;&#x7247;&#x5C3A;&#x5BF8;&#x8D8A;&#x5C0F;</td>
</tr>
<tr>
<td style="text-align:left">format</td>
<td style="text-align:left">String</td>
<td style="text-align:left">JPEG</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x538B;&#x7F29;&#x683C;&#x5F0F;&#xFF0C;&#x652F;&#x6301;&#x4E09;&#x79CD;&#x683C;&#x5F0F;&#xFF1A;JPEG&#xFF0C;PNG&#xFF0C;WEBP</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left"></td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">dstUri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x538B;&#x7F29;&#x6210;&#x529F;&#x540E;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;uri</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">202</td>
<td style="text-align:left">&#x53C2;&#x6570;&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">300</td>
<td style="text-align:left">I/O&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">301</td>
<td style="text-align:left">&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x4E0D;&#x5B58;&#x5728;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.compressImage({
  srcUri: <span class="hljs-string">&quot;tmp://abc.jpg&quot;</span>,
  quality: <span class="hljs-number">80</span>,
  radio: <span class="hljs-number">2</span>,
  format: <span class="hljs-string">&quot;JPEG&quot;</span>,
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(data.dstUri);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h4 id="unimediagetimageinfoobject">uni.media.getImageInfo(OBJECT)</h4>
<p>&#x83B7;&#x53D6;&#x56FE;&#x7247;&#x7684;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x6E90;&#x6587;&#x4EF6;&#x7684;uri</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;uri</td>
</tr>
<tr>
<td style="text-align:left">width</td>
<td style="text-align:left">Number</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x7684;&#x5BBD;&#x5EA6;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;px</td>
</tr>
<tr>
<td style="text-align:left">height</td>
<td style="text-align:left">Number</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x7684;&#x9AD8;&#x5EA6;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;px</td>
</tr>
<tr>
<td style="text-align:left">size</td>
<td style="text-align:left">Number</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x7684;&#x5927;&#x5C0F;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;Byte</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">202</td>
<td style="text-align:left">&#x53C2;&#x6570;&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">300</td>
<td style="text-align:left">I/O&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">301</td>
<td style="text-align:left">&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x4E0D;&#x5B58;&#x5728;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.getImageInfo({
  uri: <span class="hljs-string">&quot;tmp://abc.jpg&quot;</span>,
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(data.uri + data.width + data.height + data.size);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h4 id="unimediaeditimageobject">uni.media.editImage(OBJECT)</h4>
<p>&#x7F16;&#x8F91;&#x56FE;&#x7247;&#xFF0C;&#x7CFB;&#x7EDF;&#x63D0;&#x4F9B;&#x57FA;&#x7840;&#x57FA;&#x4E8E;&#x77E9;&#x5F62;&#x6846;&#x7684;&#x88C1;&#x526A;&#x56FE;&#x7247;UI&#x7EC4;&#x4EF6;&#xFF0C;&#x8FD4;&#x56DE;&#x88C1;&#x526A;&#x540E;&#x4FDD;&#x5B58;&#x7684;&#x56FE;&#x7247;&#x8DEF;&#x5F84;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">srcUri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x6E90;&#x6587;&#x4EF6;&#x7684;uri&#xFF0C;&#x4EC5;&#x652F;&#x6301;&#x672C;&#x5730;&#x56FE;&#x7247;&#x8DEF;&#x5F84;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">dstUri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x88C1;&#x526A;&#x540E;&#x56FE;&#x7247;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;uri</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">202</td>
<td style="text-align:left">&#x53C2;&#x6570;&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">300</td>
<td style="text-align:left">I/O&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">301</td>
<td style="text-align:left">&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x4E0D;&#x5B58;&#x5728;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.cropImage({
  srcUri: <span class="hljs-string">&quot;tmp://abc.jpg&quot;</span>,
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(data.dstUri);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h4 id="unimediacropimage-object">uni.media.cropImage (OBJECT)</h4>
<p>&#x6839;&#x636E;&#x8F93;&#x5165;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x5728;&#x672C;&#x5730;&#x88C1;&#x5207;&#x56FE;&#x7247;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x56FE;&#x7247;&#x672C;&#x5730;&#x5730;&#x5740;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">cropData</td>
<td style="text-align:left">Object</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x88C1;&#x5207;&#x53C2;&#x6570;&#xFF1A;{ x: 0,  y: 0,  width: 240,  height: 180,  rotate: 0,  scale: { x: 1, y: 1 }}</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">uri</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x88C1;&#x5207;&#x540E;&#x7684;&#x56FE;&#x7247;&#x5730;&#x5740;&#x3002;</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">202</td>
<td style="text-align:left">&#x53C2;&#x6570;&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">300</td>
<td style="text-align:left">I/O&#x9519;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">301</td>
<td style="text-align:left">&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x4E0D;&#x5B58;&#x5728;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.media.cropImage({
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ret</span>) </span>{
    <span class="hljs-built_in">console</span>.log(ret);
  },
  uri: <span class="hljs-string">&quot;[image location]&quot;</span>,
  cropData: {
    x: <span class="hljs-number">0</span>,
    y: <span class="hljs-number">0</span>,
    width: <span class="hljs-number">240</span>,
    height: <span class="hljs-number">180</span>,
    rotate: <span class="hljs-number">0</span>,
    scale: {
      x: <span class="hljs-number">1</span>,
      y: <span class="hljs-number">1</span>
    }
  }
});
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="system.html" class="navigation navigation-prev " aria-label="Previous page: 系统能力">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="share.html" class="navigation navigation-next " aria-label="Next page: 分享">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"图形图像","level":"1.5.7","depth":2,"next":{"title":"分享","level":"1.5.8","depth":2,"path":"api/share.md","ref":"api/share.md","articles":[]},"previous":{"title":"系统能力","level":"1.5.6","depth":2,"path":"api/system.md","ref":"api/system.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/media.md","mtime":"2018-02-25T01:59:33.447Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-04T08:24:24.953Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

